package com.qf.springbootopenapi.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * @BelongsProject: open-api-based-on-springboot
 * @BelongsPackage: com.qf.springbootopenapi.aspect
 * @Author: YuanSir
 * @CreateTime: 2022-10-19  14:52
 * @Description:
 * @Version: 1.0
 */

@Component
@Aspect //切面注解
public class MyAspect {
    
    @Pointcut("execution(* com.qf.springbootopenapi.controller..*.*(..))")
    public void myPointcut(){}
    
    @Before("myPointcut()")
    public void before(){
        System.out.println("==================myPointcut before==================");
    }
    
    @Around("myPointcut()")
    public Object around(ProceedingJoinPoint pjp) throws Throwable {
    
        System.out.println("==================myPointcut around前置==================");
        
        Object proceed = pjp.proceed();
    
        System.out.println("==================myPointcut around后置==================");
    
        return proceed;
    }
    
    @After("myPointcut()")
    public void after(){
        System.out.println("==================myPointcut after==================");
    
    }
}
